package org.snail.other.controller;

import org.apache.log4j.Logger;
import org.snail.other.service.impl.LevelServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
@Controller
public class LevelDetailController {
    private static final Logger logger =  Logger.getLogger(LevelDetailController.class);

    @Autowired
    private LevelServiceImpl levelServiceImpl;

    /*
     * 通过流的方式上传文件
     * @RequestParam("file") 将name=file控件得到的文件封装成CommonsMultipartFile 对象
     */
    @RequestMapping("levelFileUpload")
    public ModelAndView levelFileUpload(@RequestParam("file") CommonsMultipartFile file, HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("attendanceResult");
        String outPath = levelServiceImpl.levelFileUpload(file, request);
        modelAndView.addObject("outPath", outPath);
        return modelAndView;
    }


}